package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Course;
import com.hl.sfzy.entity.CourseList;
import com.hl.sfzy.mapper.CourseListMapper;
import com.hl.sfzy.service.CourseListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName CourseListServiceImpl
 * @Description TODO
 * @Author 野原新之助
 * @Date 2024年01月15日 20:41:36
 * @Version 1.0
 */
@Service
public class CourseListServiceImpl implements CourseListService {
    @Autowired
    private CourseListMapper courseListMapper;
    @Override
    public void add(CourseList entity) throws Exception {

    }

    @Override
    public void edit(CourseList entity) {
        courseListMapper.update(entity);
    }

    @Override
    public void remove(Integer id) {

    }

    @Override
    public void removeBatch(Integer[] ids) {

    }

    @Override
    public List<CourseList> find(CourseList entity) {
        return courseListMapper.select(entity);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, CourseList entity) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseList> coursesList = this.courseListMapper.select(entity);
        PageInfo<Course> pageInfo = new PageInfo(coursesList);
        Map<String, Object> pageMap = new HashMap();
        pageMap.put("list", coursesList);
        pageMap.put("total", pageInfo.getTotal());
        return pageMap;
    }

    @Override
    public CourseList findById(Integer id) {
        return courseListMapper.selectById(id);
    }
}
